package com.example.mymvvmdemo.models.main.fragment.device.adapter;

import android.content.Context;

import com.example.mymvvmdemo.base.BaseVBAdapter;
import com.example.mymvvmdemo.databinding.ItemDeviceQuickBinding;
import com.example.mymvvmdemo.entity.CommonEntity;
import com.example.mymvvmdemo.models.main.fragment.device.entity.DeviceShortEntity;
import com.example.mymvvmdemo.utils.LogUtils;
import com.example.mymvvmdemo.utils.StrUtils;

import java.util.ArrayList;

public class DeviceQuickAdapter extends BaseVBAdapter<DeviceShortEntity.DataDTO.ShortcutsDTO, ItemDeviceQuickBinding> {

    public DeviceQuickListener listener;

    public void setListener(DeviceQuickListener listener) {
        this.listener = listener;
    }

    /**
     * @param context
     */
    public DeviceQuickAdapter(Context context, ArrayList<DeviceShortEntity.DataDTO.ShortcutsDTO> list) {
        super(context);
        setDataList(list);
    }

    @Override
    protected void updateData(ItemDeviceQuickBinding bind, DeviceShortEntity.DataDTO.ShortcutsDTO item, int position) {

        String name = item.getName();
        if (!StrUtils.isEmpty(name)) {
            bind.tvQuick.setText(name);
        }

        bind.clAll.setOnClickListener(view -> {
            if (listener != null) {
                listener.onQuickClick(position);
            }
        });

    }

    public interface DeviceQuickListener {
        void onQuickClick(int position);
    }

}
